package com.wecon.dianping.common;

/**
 * @author Weikang  Wang
 * @program: com.wecon.dianping.common
 * @description: 通用返回
 * @date 2020/3/11 14:31
 */
public class CommonResult {

    /**
     * 表示请求返回处理结果，"success"或"fail"
     */
    private String status;

    /**
     * 若status=success时，则返回对应的json数据
     * 若status=fail时，则返回通用的错误码
     */
    private Object data;

    /**
     * 定义通用的创建返回对象的方法
     * @param result /
     * @return /
     */
    public static CommonResult create(Object result) {
        return CommonResult.create(result, "SUCCESS");
    }

    public static CommonResult create(Object result, String status) {
        CommonResult commonResult = new CommonResult();
        commonResult.setStatus(status);
        commonResult.setData(result);

        return commonResult;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
